﻿@using NetCore.WF.BLL
@inject IFlowService fService
@{
    var lstAll = fService.GetAll();
    ViewData["Title"] = "任务 管理";
}
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-lg-12">
            <div class="ibox float-e-margins">
                <div class="ibox-content text-center p-md ibox-content-search">
                    <form class="form-horizontal" datatable="tableGrid">

                        <div class="form-group col-md-4">
                            <label for="keyWord" class="col-md-3 control-label text-right">流程</label>
                            <div class="col-md-9">
                                <select class="select2" name="FlowId" id="FlowId">
                                    <option value="">请选择</option>
                                    @{
                                        if (lstAll != null && lstAll.Count > 0)
                                        {
                                            foreach (var item in lstAll)
                                            {
                                                <option value="@item.FlowId">@item.FlowName</option>
                                            }
                                        }
                                    }
                                </select>
                            </div>
                        </div>
                        <div class="form-group col-md-4">
                            <label for="keyWord" class="col-md-3 control-label text-right">流程状态</label>
                            <div class="col-md-9">
                                <select class="select2" name="ProcessStatus" id="ProcessStatus">
                                    <option value="">不限</option>
                                    @{
                                        var enmuLst = ConvertHelper.ToEnumList(typeof(InsStateEnum), false);
                                        foreach (var item in enmuLst)
                                        {
                                            <option value="@item.Key">@item.Value</option>
                                        }
                                    }
                                </select>
                            </div>
                        </div>

                        <div class="form-group col-md-4">
                            <label for="keyWord" class="col-md-3 control-label text-right">任务状态</label>
                            <div class="col-md-9">
                                <select class="select2" name="TaskStatus" id="TaskStatus">
                                    <option value="">不限</option>
                                    @{
                                        var enmuLst1 = ConvertHelper.ToEnumList(typeof(TaskStateEnum), false);
                                        foreach (var item in enmuLst1)
                                        {
                                            bool flag = TaskStateEnum.Activated.GetHashCode() == item.Key;
                                            @Html.Raw("<option value='" + item.Key + "' " + (flag ? "selected" : "") + " >" + item.Value + "</option>");
                                        }
                                    }
                                </select>
                            </div>
                        </div>
                        <div class="form-group col-md-4">
                            <label for="keyWord" class="col-md-3 control-label text-right">关键字</label>
                            <div class="col-md-9">
                                <input id="keyWord" name="keyWord" class="form-control" placeholder="关键字" />
                            </div>
                        </div>
                        <div>

                            @*<a class="btn  btn-danger  pull-right btn-rounded btn-outline btn-delete"><i class="fa fa-trash"></i>删  除</a>
                                <label class="pull-right">   </label>*@
                            @*<a class="btn  btn-primary pull-right btn-rounded btn-outline" asp-action="Edit"><i class="fa fa-plus"></i>新  增</a>
                                <label class="pull-right">   </label>*@
                            <a class="btn btn-primary pull-right btn-rounded btn-search"><i class="fa fa-search"></i>搜  索</a>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-lg-12">
            <div class="ibox float-e-margins">
                <div class="ibox-content text-center p-md">
                    <div class="table-responsive">
                        <table class="table table-striped table-bordered table-hover dataTables" id="tableGrid">
                            <thead>
                                <tr>
                                    <td>
                                        <div class="i-checks">
                                            <label> <input type="checkbox" class="thead checkall" title="全选" /></label>
                                        </div>
                                    </td>
                                    <td>表单名称</td>
                                    <td>任务名称</td>
                                    <td> 操作人</td>
                                    <td> 所有者</td>
                                    <td> 意见</td>
                                    <td> 状态</td>
                                    <td> 发送时间</td>
                                    <td> 执行时间</td>
                                    <td>操作</td>
                                </tr>

                            </thead>

                            <tfoot>

                                <tr>
                                    <td>
                                        <div class="i-checks">
                                            <label> <input type="checkbox" class="tfoot checkall" title="全选" /></label>
                                        </div>
                                    </td>
                                    <td>表单名称</td>
                                    <td>任务名称</td>
                                    <td> 操作人</td>
                                    <td> 所有者</td>
                                    <td> 意见</td>
                                    <td> 状态</td>
                                    <td> 发送时间</td>
                                    <td> 执行时间</td>
                                    <td>操作</td>
                                </tr>
                            </tfoot>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
@{


}
@section scripts{
    <script type="text/javascript">

        $(document).ready(function () {
            $(".form-horizontal").CustomForm({
                isValidate: false,
                isTable: false,
                Init:true,
            });
    var table = $(".dataTables").CustomForm({
    isValidate: false,
    isTable: true,
        Init:false,
    "order": [[1, "desc"]], //默认排序
    ajaxUrl: "@Url.Action("ForGrid")",
    "columns": [
    CONSTANT.DATA_TABLES.COLUMN.CHECKBOX("ProcessTaskId")

     , { "name": "a.Title", "data": "Title", "title": "表单名称", "sDefaultContent": "", "type": 'string', "format": '', "bSortable": true }
     ,{ "name": "TaskLabel", "data":"TaskLabel", "title": "任务名称", "sDefaultContent": "", "type": 'string', "format":'', "bSortable":true}

         ,{ "name": "b.AssignUser", "data":"AssignUser", "title": " 操作人", "sDefaultContent": "", "type": 'string',  "format":'', "bSortable":true  }

        ,{ "name": "b.OwnerUserId", "data":"OwnerUserId", "title": " 所有者", "sDefaultContent": "", "type": 'string', "format":'', "bSortable":true }

        , { "name": "Description", "data": "Description", "title": " 意见", "sDefaultContent": "", "type": 'string', "format": '', "bSortable": true }
        , {"name": "TaskStatus", "data": "TaskStatus", "title": " 状态", "sDefaultContent": "", "type": 'int', "format": '', "bSortable": false
            , render: function (data, type, row) {
                switch (row.TaskStatus)
                {
                    case @TaskStateEnum.Activated.GetHashCode().ToString():
                        return "已激活";
                        break;
                    case @TaskStateEnum.Executed.GetHashCode().ToString():
                        return "已执行";
                        break;
                    case @TaskStateEnum.NotActive.GetHashCode().ToString():
                        return "未激活";
                        break;
                    case @TaskStateEnum.Paused.GetHashCode().ToString():
                        return "驳回";
                        break;
                }
                return row.TaskStatus;
            }
        }
          ,{

              "name": "SendDate",
              "data": "SendDate",
              "title": " 发送时间",
              "sDefaultContent": "",
              "type": 'string',
              "format":'',
              "bSortable":true
                         , render: function (data, type, row) {
                             return row.SendDate;
                         }
          }
            ,{

                "name": "EDate",
                "data": "EDate",
                "title": " 执行时间",
                "sDefaultContent": "",
                "type": 'string',
                "format":'',
                "bSortable":true
                         , render: function (data, type, row) {
                             return row.EDate;
                         }
            }

        , CONSTANT.DATA_TABLES.COLUMN.ACTIONBTN("ProcessTaskId", "@Url.Action("Edit")")
    ],
        "fnServerParams": function(data) {
            data["FlowId"]=$("#FlowId").val();
            data["taskStatus"]=$("#TaskStatus").val();
            data["processStatus"]=$("#ProcessStatus").val();
            data.keyWord = $("#keyWord").val();//搜索参数
    }
    });

    });


    </script>
}

